package com.tronsis.distribution.activity.me;

import android.os.Bundle;
import android.widget.TextView;

import com.tronsis.distribution.R;
import com.tronsis.distribution.bean.ProductCodeFindBean;
import com.tronsis.distribution.util.CommonUtil;
import com.tronsis.distribution.util.StateUtil;
import com.tronsis.library.activity.ToolBarBaseActivity;
import com.tronsis.library.util.DateUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

public class QueryProductDetailActivity extends ToolBarBaseActivity {

    @BindView(R.id.tv_num)
    TextView mTvNum;
    @BindView(R.id.tv_product_name)
    TextView mTvProductName;
    @BindView(R.id.tv_user)
    TextView mTvUser;
    @BindView(R.id.tv_nick_name)
    TextView mTvNickName;
    @BindView(R.id.tv_role)
    TextView mTvRole;
    @BindView(R.id.tv_level)
    TextView mTvLevel;
    @BindView(R.id.tv_region)
    TextView mTvRegion;
    @BindView(R.id.tv_time)
    TextView mTvTime;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_query_product_detail);
        ButterKnife.bind(this);
        setTitle(true, "产品信息");

        ProductCodeFindBean productDetailBean = (ProductCodeFindBean) getIntent().getSerializableExtra("ProductCodeFindBean");
        if (productDetailBean != null) {
            mTvNum.setText(productDetailBean.getProductCode());
            mTvProductName.setText(productDetailBean.getProductName());
            mTvUser.setText(productDetailBean.getPhone());
            if (productDetailBean.getReceiver() != null) {
                mTvNickName.setText(productDetailBean.getReceiver().getName());
                mTvRole.setText(StateUtil.getRoleString(mContext, productDetailBean.getReceiver().getRole()));
                mTvLevel.setText(StateUtil.getLevelText(productDetailBean.getReceiver().getLevel(),productDetailBean.getReceiver().isUnited()));
                mTvRegion.setText(CommonUtil.getRegionString(productDetailBean.getReceiver().getRegion()));
            }else {
                mTvRole.setText("-");
                mTvLevel.setText("-");
                ProductCodeFindBean.ReceiverAddrBean receiverAddr = productDetailBean.getReceiverAddr();
                if (receiverAddr != null) {
                    mTvNickName.setText(receiverAddr.getName());
                    mTvRegion.setText(CommonUtil.getRegionString(receiverAddr.getRegion()));
                }

            }
            mTvTime.setText(DateUtil.getDateTimeString(productDetailBean.getScanOn()));
        }
    }


}
